<template>
  <div v-if="cellList.length">
    <van-cell-group>
      <div v-for="i in cellList" :key="i.id" style="display: flex; margin: 5px 0; border-bottom: 1px solid #eee" @click="cellClick(i)">
        <van-image width="20%" height="18vw" style="padding: 4px;border-radius: 20px; overflow: hidden" :src="i.url | imageUri" />
        <van-cell :label="$t.formatDate(new Date(i.updated)) + ' ' + i.userName">
          <template #title>
            <span class="custom-title">{{ i.label }}</span>
          </template>
          <template #right-icon>
            <van-badge :content="i.star">
              <van-icon name="good-job-o" />
            </van-badge>
          </template>
        </van-cell>
      </div>
    </van-cell-group>
  </div>
</template>

<script>
import { mapActions } from 'vuex'

export default {
  data() {
    return {
      cellList: []
    }
  },
  created() {
    this.blog().then((res) => {
      if (res.data.ok === 10) {
        console.log(res)
        this.cellList = res.data.data
      }
    })
  },
  methods: {
    cellClick(data) {
      console.log(data)
      this.$router.push(`/blogdetail/${data._id}?type=rz`)
    },
    ...mapActions(['blog'])
  }
}
</script>

<style lang="scss" scoped>
</style>
